package com.teapos.service;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.teapos.dao.CustomerDao;
import com.teapos.util.Maps;
import com.teapos.util.Tool;

@SuppressWarnings("rawtypes")
@Service
public class CustomerService {
	
	@Autowired
	private CustomerDao customerDao;
	
	public List queryCustomers(String name, String tel) {
		if(StringUtils.isNotBlank(name)) name = "%"+name+"%";
		if(StringUtils.isNotBlank(tel)) tel = "%"+tel+"%";
		return customerDao.queryCustomers(Maps.newHashMap("name", name, "tel", tel));
	}

	public int addCustomer(Map map) {
		customerDao.addCustomer(map);
		return Tool.toInt(map.get("customerId"));
	}

}
